home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1994, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- /*************************************************************************
- *
- * WCommonDialog -- Base CommonDialog class
- *
- *
- * Events:
- *
- * Change --
- *
- * Close --
- *
- * CommonDialogPrompt --
- *
- * Create --
- *
- * Destroy --
- *
- * Help --
- *
- * InitializationDone --
- *
- * MessageHook --
- *
- *************************************************************************/
-
- #ifndef _WCOMDLG_HPP_INCLUDED
- #define _WCOMDLG_HPP_INCLUDED
- #pragma once
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WEVENTD_HPP_INCLUDED
- #include "weventd.hpp"
- #endif
-
- #ifndef _WFILPATH_HPP_INCLUDED
- #include "wfilpath.hpp"
- #endif
-
- #ifndef _WRESID_HPP_INCLUDED
- #include "wresid.hpp"
- #endif
-
- #ifndef _WMODULE_HPP_INCLUDED
- #include "wmodule.hpp"
- #endif
-
- class WWindow;
- class WModelessDialog;
- class WDialog;
- class WModule;
-
-
- enum WCommonDialogError {
- // WCommonDialog general errors
- WCDCDErrorNoError = 0x0000,
- WCDCDErrorGeneralCodes = 0x0000,
- WCDCDErrorStructSize = 0x0001,
- WCDCDErrorInitialization = 0x0002,
- WCDCDErrorNoTemplate = 0x0003,
- WCDCDErrorNoHINSTANCE = 0x0004,
- WCDCDErrorLoadStrFailure = 0x0005,
- WCDCDErrorFindResFailure = 0x0006,
- WCDCDErrorLoadResFailure = 0x0007,
- WCDCDErrorLockResFailure = 0x0008,
- WCDCDErrorMemAllocFailure = 0x0009,
- WCDCDErrorMemLockFailure = 0x000A,
- WCDCDErrorNoHook = 0x000B,
- WCDCDErrorRegisterMsgFail = 0x000C,
- WCDCDErrorDialogFailure = 0xFFFF,
-
- // WPrintDialog specific errors
- WCDPDErrorPrinterCodes = 0x1000,
- WCDPDErrorSetupFailure = 0x1001,
- WCDPDErrorParseFailure = 0x1002,
- WCDPDErrorRetDefFailure = 0x1003,
- WCDPDErrorLoadDrvFailure = 0x1004,
- WCDPDErrorGetDevModeFail = 0x1005,
- WCDPDErrorInitFailure = 0x1006,
- WCDPDErrorNoDevices = 0x1007,
- WCDPDErrorNoDefaultPrn = 0x1008,
- WCDPDErrorDNDMMismatch = 0x1009,
- WCDPDErrorCreateICFailure = 0x100A,
- WCDPDErrorPrinterNotFound = 0x100B,
- WCDPDErrorDefaultDifferent = 0x100C,
-
- // WFontDialog specific errors
- WCDCFErrorChooseFontCodes = 0x2000,
- WCDCFErrorNoFonts = 0x2001,
- WCDCFErrorMaxLessThanMin = 0x2002,
-
- // WFileDialog specific errors
- WCDFNErrorFileNameCodes = 0x3000,
- WCDFNErrorSubclassFailure = 0x3001,
- WCDFNErrorInvalidFileName = 0x3002,
- WCDFNErrorBufferTooSmall = 0x3003,
-
- // WFindReplaceDialog specific errors
- WCDFRErrorFindReplaceCodes = 0x4000,
- WCDFRErrorBufferLengthZero = 0x4001,
-
- // WColorDialog specific errors
- WCDCCErrorChooseColorCodes = 0x5000,
- };
-
- struct WNewFileTypeEventData : public WEventData {
- WULong filterIndex; // NOTE: 1-based, not 0-based
- };
-
- struct WSharingViolationEventData : public WEventData {
- WChar * fileName;
- };
-
- // The CommonDialogPrompt event occurs immediately before and then
- // immediately after a common dialog is displayed. This allows
- // the advanced user to access and modify the raw data structure
- // that is passed to the native API common dialog functions.
-
- struct WCommonDialogPromptEventData : public WEventData {
- WBool before; // if true, event is occurring before prompt
- WDWord returnedFromPrompt; // value returned from prompt
- void *promptData; // pointer to raw data used for prompt
- };
-
- //
- // WCommonDialog
- //
-
- class WCMCLASS WCommonDialog : public WEventGenerator {
- WDeclareSubclass( WCommonDialog, WEventGenerator );
-
- public:
- WCommonDialog();
-
- ~WCommonDialog();
-
- /********************************************************
- * Properties
- ********************************************************/
-
- // Dialog
- //
- // Returns a pointer to a WDialog that can be used to
- // manipulate the common dialog. For modal dialogs
- // this property only returns non-NULL when the
- // dialog is being displayed and thus is typically only
- // used within events.
-
- WDialog *GetDialog();
-
- // Error
-
- WCommonDialogError GetError() const;
-
- // ModelessDialog
- //
-
- WModelessDialog *GetModelessDialog();
-
- // Owner
- //
- // Sets/gets the form that owns the dialog.
-
- WWindow *GetOwner() const;
- WBool SetOwner( WWindow *owner );
-
- // TemplateID
- //
- // Sets/gets the resource ID that defines the template
- // to use for the dialog. 0 means no template is used.
-
- WResourceID GetTemplateID() const;
- WBool SetTemplateID( WResourceID id );
-
- // TemplateModule
- //
- // Sets/gets the module for the template. A value of
- // NULL means use the application module.
-
- WModule GetTemplateModule() const;
- WBool SetTemplateModule( const WModule & module );
-
- // Title
- //
- // The title used when displaying the dialog. The
- // title may be a null string, in which case a default
- // value is used.
-
- WString GetTitle() const;
- WBool SetTitle( const WChar *title );
-
- /********************************************************
- * Methods
- ********************************************************/
-
- // Abort
- //
- // Causes the dialog to be closed as if the user had
- // cancelled it.
-
- WBool Abort() const;
-
- /********************************************************
- * Notifications
- ********************************************************/
-
- void OnDialogInitialize( WWindowHandle hWnd, WWindowHandle focus,
- WBool modal=TRUE );
- void OnDialogDestroy();
-
- /********************************************************
- * Event handlers
- ********************************************************/
-
- WBool MessageHookEventHandler( WCommonDialog * dialog,
- WMessageHookEventData * event );
-
- /********************************************************
- * Data members
- ********************************************************/
-
- protected:
- WWindowHandle _hWnd;
- WBool _isModal;
- WDialog *_dialog;
- WModelessDialog *_modelessDialog;
- WWindow *_owner;
- WModule _templateModule;
- WResourceID _templateID;
- WBool _hasUserHook;
- WString _title;
-
- // Internal use only
-
- public:
- WBool HasUserHook() const { return _hasUserHook; }
- };
-
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WCOMDLG_HPP_INCLUDED
-